home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRSUFF.C < prev    next >
Text File  |  1993-01-04  |  896b  |  29 lines

  1.  
  2. /*  File   : strsuff.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 11 April 1984
  5.     Defines: strsuff()
  6.  
  7.     strsuff(src, suffix)
  8.     checks whether suffix is a suffix of src.  If it is not, the  result
  9.     is NullS.  If it is, the result is a pointer to the character of src
  10.     where suffix starts (which is the same as src+strlen(src)-strlen(prefix) ).
  11.     See strpref.c for a comment about using if (strsuff(...)) in C.
  12. */
  13.  
  14. #include "strings.h"
  15.  
  16. char *strsuff(src, suffix)
  17.     register char *src, *suffix;
  18.     {
  19.         register int L; /* length of suffix */
  20.  
  21.         for (L = 0; *suffix++; L++)
  22.             if (!*src++) return NullS;
  23.         while (*src++) ;
  24.         for (--src, --suffix; --L >= 0; )
  25.             if (*--src != *--suffix) return NullS;
  26.         return src;
  27.     }
  28.  
  29.